﻿using FluentNHibernate.Mapping;
using ScoutersLog.Model;

namespace ScoutersLog.DataAccess.Mappings
{
    public class UnitMap : ClassMap<Unit>
    {
        public UnitMap()
        {
            // ReSharper disable DoNotCallOverridableMethodsInConstructor
            //   Required for O/R mapping
            Id(x => x.Id)
                .Column("unit_id")
                .GeneratedBy.Native();
            // ReSharper restore DoNotCallOverridableMethodsInConstructor
            References(x => x.ParentCouncil)
                .Column("council_id");
            References(x => x.BSAUnitType)
                .Column("unit_type_code");
            Map(x => x.UnitNumber)
                .Column("unit_number");
            Map(x => x.District)
                .Column("district_name")
                .Length(50);
            Map(x => x.CharteringOrganization)
                .Column("chartering_organization_name")
                .Length(50);
        }
    }
}
